package ph.com.gs3.formalistics.view.valueobjects.parsers;

import ph.com.gs3.formalistics.model.valueobjects.business.User;
import ph.com.gs3.formalistics.model.valueobjects.business.document.OutgoingDocument;
import ph.com.gs3.formalistics.model.valueobjects.business.form.Form;
import ph.com.gs3.formalistics.view.valueobjects.UserActionListViewItem;

public class OutgoingDocumentParser extends UserActionListViewItemParser {

	public static UserActionListViewItem toUserActionListItem(Form form, OutgoingDocument outgoingDocument,
	        User documentOwner) {

		UserActionListViewItem actionItem = new UserActionListViewItem();

		// @formatter:off
		actionItem.documentDbId 	= outgoingDocument.getId();
		actionItem.documentWebId	= outgoingDocument.getDocumentWebId();
		actionItem.formWebId		= outgoingDocument.getDocumentFormWebId();
		actionItem.authorWebId		= Integer.toString(documentOwner.getWebId());
		actionItem.server			= documentOwner.getAccountServer();
		
		actionItem.header 			= outgoingDocument.getDocumentFormName();
		actionItem.subheader 		= documentOwner.getDisplayName();
		actionItem.date 			= formatDate(outgoingDocument.getDateIssued());

		actionItem.contentsHeader	= "Outgoing document";
		actionItem.contentsBody 	= generateUserActionListItemContentsFromFields(form, outgoingDocument.getFieldValues());

		actionItem.footerHeader		= "Issued Action:";
		actionItem.footerBody 		= outgoingDocument.getAction();
		actionItem.imageURL 		= documentOwner.getImageURL();
		
		actionItem.isStarred		= false;
		actionItem.availableActions	= null;
				
		//	hide all actions
		actionItem.showActionsButton	= false;
		actionItem.showStarButton 		= false;
		actionItem.showCommentButton	= false;
		
		// @formatter:on

		return actionItem;
	}
}
